import { Component, ViewChild } from '@angular/core';
import { IonicPage, NavController, NavParams, TextInput } from 'ionic-angular';
import { BusiProvider } from '../../providers/busi/busi';
import { NativeProvider } from '../../providers/native/native';
import { summaryFileName } from '@angular/compiler/src/aot/util';

/**
 * Generated class for the SummaryPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-summary',
  templateUrl: 'summary.html',
})
export class SummaryPage {
  @ViewChild('summarytextarea') summarytextarea: TextInput;
  mettingid:any;
  summary:any;
  constructor(public navCtrl: NavController, public navParams: NavParams,public busi:BusiProvider,private native:NativeProvider) {
    this.mettingid = this.navParams.get("mettingid");
    this.summary = this.navParams.get("hyzj");
  }

  ionViewDidLoad() {
    setTimeout(() => {
      this.summarytextarea.setFocus();
    }, 1000);
    console.log('ionViewDidLoad SummaryPage');
  }
  saveSummary(){
    if(this.summary==null){
      this.native.alert("会议总结为空！");
      return;
    }
    this.busi.saveSummary(this.mettingid,this.summary).subscribe(
      ()=>{
        this.native.showToast("保存成功！");
        this.navCtrl.pop();
      },
      error=>{

      }
    );
  }

}
